package com.quanshu.shop.order.custom;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者  李哲
 * 创建时间 2018/8/27
 * 邮箱 lizhetongliao@163.com
 * 说明
 **/
public class InsufficientBanlance1Dialog extends Dialog {
    @BindView(R.id.balance_txt1)
    TextView balanceTxt1;
    @BindView(R.id.balance_txt2)
    TextView balanceTxt2;
    @BindView(R.id.balance_fl_close)
    FrameLayout balanceFlClose;
    @BindView(R.id.line1)
    View line1;
    @BindView(R.id.balance_txt3)
    TextView balanceTxt3;
    @BindView(R.id.line2)
    View line2;
    @BindView(R.id.balance_txt4)
    TextView balanceTxt4;
    private Context mContext;
    private InsufficientBanlanceDialog.OnInsufficientBanlanceListener onInsufficientBanlanceListener;

    public InsufficientBanlance1Dialog(Context context) {
        super(context, R.style.CartDialogWindow);
        mContext = context;
    }

    public void show() {
        super.show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_insufficient1_banlance);
        ButterKnife.bind(this);
        setCancelable(true);//点击外部不可dismiss
        setCanceledOnTouchOutside(true);
        Window window = this.getWindow();
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
        initView();
    }

    private void initView() {
        RxViewHelper.getInstance().clicks(balanceFlClose, aVoid ->
                dismiss()
        );
        RxViewHelper.getInstance().clicks(balanceTxt3, aVoid ->
                {
                    dismiss();

                }

        );
        RxViewHelper.getInstance().clicks(balanceTxt4, aVoid ->
                {
                    if (onInsufficientBanlanceListener != null) {
                        onInsufficientBanlanceListener.payAllMoney();
                    }
                    dismiss();

                }

        );
    }


    public InsufficientBanlance1Dialog setOnDeleteAddressListener(InsufficientBanlanceDialog.OnInsufficientBanlanceListener onInsufficientBanlanceListener1) {
        onInsufficientBanlanceListener = onInsufficientBanlanceListener1;
        return this;
    }
}
